<?php
namespace Admin\Controller;
use Think\Controller;
class CaseShowController extends BaseController {
    public function index(){
    	$this->login_verify();
    	// APP开发
    	$case=M('case');
        $caselist=$case->select();
        $this->assign("caselist",$caselist);
        // JAVA展示
        $casejava=M('casejava');
        $casejavalist=$casejava->select();
        $this->assign("casejavalist",$casejavalist);
        // UI展示
        $caseui=M('caseui');
        $caseuilist=$caseui->select();
        $this->assign("caseuilist",$caseuilist);
        // H5展示
        $caseh5=M('caseh5');
        $caseh5list=$caseh5->select();
        $this->assign("caseh5list",$caseh5list);

        $this->assign("type",$_GET['type']);
        $this->display();
    }
	// APP开发
     public function pro_display(){
     	$data['content']=$_POST['content'];
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     2097152 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->saveName = 'time';
	    $upload->subName = 'case';
	    $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['case']);
	    if(!$info) {// 上传错误提示错误信息
	        $this->error($upload->getError());
	    }else{// 上传成功 获取上传文件信息
	        $case=M('case');
	        $data['imgurl']='Uploads/'.$info['savepath'].$info['savename'];
	        if($case->data($data)->add()){
	        	$this->success("上传成功",U('CaseShow/index',array("type"=>1)));
	        }else{
	        	$this->error("上传失败");
	        }
	    }
	}
	// JAVA展示
	public function java_display(){
		$data['content']=$_POST['content'];
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     2097152 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->saveName = 'time';
	    $upload->subName = 'casejava';
	    $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录	    
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['casejava']);
	    if(!$info) {// 上传错误提示错误信息
	        $this->error($upload->getError());
	    }else{// 上传成功 获取上传文件信息
	        $casejava=M('casejava');
	        $data['content']=$_POST['content'];
	        $data['imgurl']='Uploads/'.$info['savepath'].$info['savename'];
	        if($casejava->data($data)->add()){
	        	$this->success("上传成功",U('CaseShow/index',array("type"=>2)));
	        }else{
	        	$this->error("上传失败");
	        }
	    }
    }
	// UI展示
    public function ui_display(){
    	$data['content']=$_POST['content'];
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     2097152 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->saveName = 'time';
	    $upload->subName = 'caseui';
	    $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['caseui']);
	    if(!$info) {// 上传错误提示错误信息
	        $this->error($upload->getError());
	    }else{// 上传成功 获取上传文件信息
	        $caseui=M('caseui');
	        $data['content']=$_POST['content'];
	        $data['imgurl']='Uploads/'.$info['savepath'].$info['savename'];
	        if($caseui->data($data)->add()){
	        	$this->success("上传成功",U('CaseShow/index',array("type"=>3)));
	        }else{
	        	$this->error("上传失败");
	        }
	    }
	}
	// H5展示
	public function h5_display(){
		$data['content']=$_POST['content'];
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     2097152 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->saveName = 'time';
	    $upload->subName = 'caseh5';
	    $upload->rootPath  =      './Uploads/'; // 设置附件上传根目录
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['caseh5']);
	    if(!$info) {// 上传错误提示错误信息
	        $this->error($upload->getError());
	    }else{// 上传成功 获取上传文件信息
	        $caseh5=M('caseh5');
	        $data['imgurl']='Uploads/'.$info['savepath'].$info['savename'];
	        if($caseh5->data($data)->add()){
	        	$this->success("上传成功",U('CaseShow/index',array("type"=>4)));
	        }else{
	        	$this->error("上传失败");
	        }
	    }
	}

	// APP开发
    public function caseDel(){
    	$id=I('get.id');
    	$case=M('case');
    	if($case->where('id='.$id)->delete()){
	        	$this->success("删除成功",U('CaseShow/index',array("type"=>1)));
    	}else{
	        	$this->error("删除失败");
    	}
    	// var_dump($id);
    }
	// JAVA展示
    public function casejavaDel(){
    	$id=I('get.id');
    	$casejava=M('casejava');
    	if($casejava->where('id='.$id)->delete()){
         	$this->success("删除成功",U('CaseShow/index',array("type"=>2)));
    	}else{
	     	$this->error("删除失败");
    	}
    }
	// UI展示
    public function caseuiDel(){
    	$id=I('get.id');
    	$casejava=M('caseui');
    	if($caseui->where('id='.$id)->delete()){
         	$this->success("删除成功",U('CaseShow/index',array("type"=>3)));
    	}else{
	     	$this->error("删除失败");
    	}
    }
    // H5展示
    public function caseh5Del(){
    	$id=I('get.id');
    	$caseh5=M('caseh5');
    	if($caseh5->where('id='.$id)->delete()){
         	$this->success("删除成功",U('CaseShow/index',array("type"=>4)));
    	}else{
	     	$this->error("删除失败");
    	}
    }
}